#ifndef LOGGER_H_
#define LOGGER_H_

#include <vector>
#include <string>
#include <iostream>

using namespace std;

#define l_debug *(logger.debug)

namespace phnq
{
	namespace kit
	{
		namespace log
		{
			class Appender;
			
			typedef clock_t LoggerTime;
			
			class Logger
			{
				public:
					static const short NONE = 0;
					static const short CRITICAL = 1;
					static const short ERROR = 2;
					static const short WARNING = 3;
					static const short INFO = 4;
					static const short DEBUG = 5;
					static Logger* get(string category);
					static void setGlobalLevel(short level);

					string getCategory();
					void setAppender(Appender *appender);
					void critical(const char *msg, ...);
					void critical(LoggerTime start, const char *msg, ...);
					void error(const char *msg, ...);
					void error(LoggerTime start, const char *msg, ...);
					void warning(const char *msg, ...);
					void warning(LoggerTime start, const char *msg, ...);
					void info(const char *msg, ...);
					void info(LoggerTime start, const char *msg, ...);
					void debug(const char *msg, ...);
					void debug(LoggerTime start, const char *msg, ...);
					LoggerTime time();
					
				private:
					string category;
					char lineBuf[4096];
					Appender *appender;
					Logger(string category);
					void write(short level, LoggerTime time, const char *msg, va_list &argList);
			};
		}
	}
}

#endif // LOGGER_H_
